package com.feiwo.nonego.rpc.proxy.asm;

import com.feiwo.nonego.rpc.proxy.api.BaseProxyFactory;
import com.feiwo.nonego.rpc.proxy.api.ProxyFactory;
import com.feiwo.nonego.rpc.proxy.asm.proxy.AsmProxy;
import com.feiwo.nonego.rpc.spi.annotation.SPIClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 *
 * @author feiwo 2025-08-15
 */
@SPIClass
public class AsmProxyFactory<T> extends BaseProxyFactory<T> implements ProxyFactory {

    private static final Logger logger = LoggerFactory.getLogger(AsmProxyFactory.class);

    @SuppressWarnings("unchecked")
    @Override
    public <T> T getProxy(Class<T> clazz) {
        try {
            return (T) AsmProxy.newProxyInstance(this.getClass().getClassLoader(), new Class<?>[]{clazz}, objectProxy);
        } catch (Exception e) {
            logger.error("asm proxy throws ex ---> ", e);
        }
        return null;
    }
}
